<?php

function new_product_data_render() {
    $sql = "
    SELECT node.nid AS nid, node.title AS node_title, node_counter.totalcount AS node_counter_totalcount, node.type AS node_type, node.vid AS node_vid, uc_products.sell_price AS uc_products_sell_price, img.field_image_cache_fid AS fid
    FROM node node
    LEFT JOIN node_counter node_counter ON node.nid = node_counter.nid
    LEFT JOIN uc_products uc_products ON node.vid = uc_products.vid
    LEFT JOIN content_field_image_cache img ON img.nid = node.nid
    WHERE ( node.status <>0 AND img.delta =0 ) AND ( node_counter.totalcount >0 ) AND ( node.type IN ( 'product' ) )
    ORDER BY node_counter_totalcount DESC LIMIT 0 , 5
    ";

    $rs = db_query($sql);

    $result = array();
    while( $node = db_fetch_object($rs) ){
        $result[] = $node;
    }
    
    return $result;

}
?>

